import { createRouter, createWebHistory } from 'vue-router'
import Home from '@/views/front/Home/Home.vue'
import Layout from '@/views/front/Layout/Layout.vue'
import UserLogin from '@/views/front/UserLogin.vue'
import Product from '@/views/front/Product/Product.vue'
import Details from '@/views/front/Product/Details.vue'
import ShoppingCart from '@/views/front/Cart/ShoppingCart.vue'
import Checkout from '@/views/front/Order/checkout.vue'
import Personal from '@/views/front/User/Personal.vue'
import Orders from '@/views/front/User/components/Orders.vue'
import Address from '@/views/front/User/components/Address.vue'
import Favorites from '@/views/front/User/components/Favorites.vue'
import Settings from '@/views/front/User/components/Settings.vue'
import DashboardView from '@/views/back/DashboardView.vue'
import BackHome from '@/views/back/Home/BackHome.vue'
import Carousel from '@/views/back/Carousel/Carousel.vue'
import Classify from '@/views/back/Classify/Classify.vue'
import BackOrder from '@/views/back/Order/BackOrder.vue'
import BackProduct from '@/views/back/Product/BackProduct.vue'
import Staff from '@/views/back/Staff/Staff.vue'
import Statistics from '@/views/back/Statistics/Statistics.vue'
import User from '@/views/back/User/User.vue'
import AdminLogin from '@/views/back/AdminLogin.vue'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      component: Layout,
      children: [{
        path: '',
        name: 'Home',
        component: Home,
      },
      {
        path: 'product',
        name: 'Product',
        component: Product
      },
      {
        path: 'details',
        name: 'Details',
        component: Details
      },
      {
        path: 'shopping',
        name: 'ShoppingCart',
        component: ShoppingCart
      },
      {
        path: 'personal',
        name: 'Personal',
        component: Personal,
        children: [
          {
            path: '',
            name: 'Orders',
            redirect: 'orders'
          },
          {
            path: 'orders',
            name: 'UserOrders',
            component: Orders
          },
          {
            path: 'address',
            name: 'Address',
            component: Address
          },
          {
            path: 'favorites',
            name: 'Favorites',
            component: Favorites
          },
          {
            path: 'settings',
            name: 'Settings',
            component: Settings
          }
        ]
      },
      {
        path: 'checkout',
        name: 'Checkout',
        component: Checkout
      }
      ]
    },
    {
      path: '/back',
      component: DashboardView,
      children: [
        {
          path: '',
          name: 'DashboardDefault',
          redirect: { name: 'BackHome' }
        },
        {
          path: 'home',
          name: 'BackHome',
          component: BackHome,
          meta: {
            title: '工作台',
            breadcrumb: ['工作台']
          }
        },
        {
          path: 'carousel',
          name: 'Carousel',
          component: Carousel,
          meta: {
            title: '轮播图管理',
            breadcrumb: ['工作台', '轮播图管理']
          }
        },
        {
          path: 'order',
          name: 'BackOrder',
          component: BackOrder,
          meta: {
            title: '订单管理',
            breadcrumb: ['工作台', '订单管理']
          }
        },
        {
          path: 'product',
          name: 'BackProduct',
          component: BackProduct,
          meta: {
            title: '产品管理',
            breadcrumb: ['工作台', '产品管理']
          }
        },
        {
          path: 'staff',
          name: 'Staff',
          component: Staff,
          meta: {
            title: '员工管理',
            breadcrumb: ['工作台', '员工管理']
          }
        },
        {
          path: 'statistics',
          name: 'Statistics',
          component: Statistics,
          meta: {
            title: '数据统计',
            breadcrumb: ['工作台', '数据统计']
          }
        },
        {
          path: 'user',
          name: 'User',
          component: User,
          meta: {
            title: '用户管理',
            breadcrumb: ['工作台', '用户管理']
          }
        },
        {
          path: 'classify',
          name: 'Classify',
          component: Classify,
          meta: {
            title: '分类管理',
            breadcrumb: ['工作台', '分类管理']
          }
        }
      ]
    },
    {
      path: '/userlogin',
      name: 'UserLogin',
      component: UserLogin,
    }, {
      path: '/adminlogin',
      name: 'AdminLogin',
      component: AdminLogin,
    }
  ]
})

export default router
